﻿@model IEnumerable<CSF.Security.Data.UserAccount>
@{
    ViewBag.Title = "Index";
    ViewBag.SubTitle = "User Account";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div id="applicationPanel" class="easyui-panel" title="Grid" icon="icon-save" collapsible="true"
    style="width: auto; padding: 10px; background: #fafafa;">
    @using (Html.BeginForm("Index", "CustomerUserAccount", FormMethod.Get))
    { 
        @Html.Hidden("SessionId", Request["SessionId"])
        <div style="text-align: right">
            &nbsp;&nbsp;User Name:<input id="UserName" name="UserName" />
            Email:<input id="Email" name="Email" />
            <a href="javascript:submitSearch();" class="easyui-linkbutton" iconcls="icon-search"
                plain="true">Search</a>
            <input id="search" type="submit" value="submit" style="display: none" />
        </div>
       
    }
    @using (Html.BeginForm("Delete", "CustomerUserAccount"))
    {
        @Html.Hidden("toUrl", Request.Url.ToString())
        <div id="toolbar" style="width: 90%">
            &nbsp;&nbsp;<input type="checkbox" id="chkAll" name="chkAll" />Select All&nbsp;&nbsp;
            <a href="@Url.Action("Add", "CustomerUserAccount", new { cid = Request["cid"] })" class="easyui-linkbutton" iconcls="icon-add" plain="true">
                Add</a> &nbsp;&nbsp;<a href="javascript:submitToggleActive();" class="easyui-linkbutton"
                    iconcls="icon-no" plain="true">Delete</a>
        </div>
        <div id="grid">
            @{  var grid = new WebGrid(source: Model, defaultSort: "UserName", rowsPerPage: 13, ajaxUpdateContainerId: "grid");    
                @grid.GetHtml(
                               tableStyle: "webGrid",
                               headerStyle: "header",
                               alternatingRowStyle: "alt",
                               footerStyle: "foot",
                                columns: grid.Columns(
                             grid.Column(format: @<input  name="Id" type="checkbox" value="@item.Id" />),
                             grid.Column("UserName", "User Name"),
                             grid.Column("Email", "Email"),
                             grid.Column("Password", "Password"),
                             grid.Column("FirstName", "First Name"),
                             grid.Column("LastName", "Last Name"),
                             //grid.Column("LastActivityDate", "LastActivityDate"),
                             //grid.Column("LastLockoutDate", "LastLockoutDate"),
                             //grid.Column("LastLoginDate", "LastLoginDate"),
                             //grid.Column("LastPwdChgDate", "LastPwdChgDate"),
                             //grid.Column("PwdAnswerAttemps", "PwdAnswerAttemps"),
                             //grid.Column("PwdAttemps", "PwdAttemps"),
                             //grid.Column("PwdAttempStart", "PwdAttempStart"),
                            //grid.Column("PwdAttempStart", "PwdAttempStart"),
                             //grid.Column("PwdQuestion", "PwdQuestion"),
                             //grid.Column("Comment", "Comment"),
                             //grid.Column("IsApproved", "IsApproved"),
                             //grid.Column("IsLockout", "IsLockout"),
                            //grid.Column("IsDisable", "IsDisable"),
                            grid.Column("IsStaff", "Is Staff"),
                           //grid.Column("IsBuiltin", "IsBuiltin"),
                           //grid.Column("ApproveBy", "ApproveBy"),
                           //grid.Column("ApproveTime", "ApproveTime"),
                          //grid.Column("CreateBy", "CreateBy"),
                          //grid.Column("CreateTime", "CreateTime"),
                              grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { id = item.Id })),
                             grid.Column(format: (item) => Html.ActionLink("Delete", "Delete", new { id = item.Id, toUrl = Request.Url.ToString() }))
                                                                             ),
                                                              fillEmptyRows: !IsPost,
                                                              mode: WebGridPagerModes.All,
                                                              firstText: "First Page",
                                                              previousText: "Previous Page",
                                                              nextText: "Next Page",
                                                              lastText: "Last Page",
                                                              numericLinksCount: 15

                                                        ) 
            }
        </div>
        <br />
        <input id="submit" type="submit" value="submit" style="display: none" />    
    }
</div>
<script type="text/javascript">
    $('#chkAll').click(function () {
        $(':checkbox[name="Id"]').attr('checked', $(this).attr('checked'));
    });
    function submitToggleActive() {
        $('#submit').click();
    }
    function submitSearch() {
        $('#search').click();
    }
</script>
